// 2014-02-01 Tyrghen
//---------------------------------------------
// Usage:
//  [] call edt_fnc_;
//---------------------------------------------
// Purpose:
// 
// 
// Parameters:
// - 
//
// Returns:
// 
//---------------------------------------------
// Objectif:
// 
//
// Paramètres:
// - 
//
// Renvoie:
// 
//---------------------------------------------

//#define __FORCE_TRACE__
//#define __FORCE_DEBUG__
//#define __FORCE_INFO__
#define THIS_FILE "editor\fn_create.sqf"
#include <tmf_constants.h>
#include <tmf_macros.h>

if (!isServer) exitWith { TRACE("Not Server") };

TRACE_1("Start",_this);
TMFPROFILERSTART;

private ["_type","_marker","_error","_special","_shape","_obj"];
DEFAULT_PARAM(_type,0,"");
DEFAULT_PARAM(_marker,1,"");
DEFAULT_PARAM(_special,2,"");

_obj = objNull;

_error = false;
if (IS_STRING(_type)) then { _error = (_type == "") };

_shape = [_marker] call FFUNC(toShape);
if (count (_shape select TMF_SHAPE_CENTER) <= 0) then { _error = true };
if (!_error) then {
	_obj = [TMF_SERVER_INSTANCE_ID, _type,(_shape select TMF_SHAPE_CENTER),[],((_shape select TMF_SHAPE_WIDTH) max (_shape select TMF_SHAPE_HEIGHT)),_special] call FFUNC(createVehicle);
	if (((_shape select TMF_SHAPE_WIDTH) max (_shape select TMF_SHAPE_HEIGHT)) <= 0) then {
		_obj setPos (_shape select TMF_SHAPE_CENTER);
	};
	_obj setDir (_shape select TMF_SHAPE_ANGLE);
	TRACE_1("End",ARR_3(_obj, typeof _obj, getPos _obj));
} else {
	TRACE("End");
};
TMFPROFILERSTOP;
_obj;